package com.jhws.business.device.api;

import com.jhws.common.base.bo.JsonRespData;
import com.jhws.core.push.IosApnsPushy;
import com.jhws.core.push.IosPushyMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/call")
public class CallApi {
    @Resource
    IosPushyMap pushys;

    @ResponseBody
    @RequestMapping("anon/sync")
    public JsonRespData iosSendCallSyncMsg(String p12FileName,String password,String token,String username,
                                           String title, String caller, String callee,String msg,String type,boolean isProd) throws Exception{
        IosApnsPushy pushy = pushys.get(p12FileName);
        if(pushy == null){
            pushy = new IosApnsPushy(p12FileName,password);
            pushys.set(p12FileName,pushy);
        }

        Map<String,String> custom = new HashMap<>();
        custom.put("username",username);
        custom.put("type",type);
        custom.put("caller",caller);
        custom.put("callee",callee);
        pushy.push(token,title,msg,custom,isProd);
        return new JsonRespData("",1,"");
    }
}
